package com.heima.admin.controller;

import com.heima.admin.entity.AdSensitive;
import com.heima.admin.service.AdSensitiveService;
import com.heima.common.dtos.PageResult;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.admin.dtos.SensitiveDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping
public class SensitiveController {

    @Autowired
    private AdSensitiveService adSensitiveService;


    /**
     * 敏感词管理--分页显示列表
     *
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/sensitive/list")
    public PageResult<AdSensitive> sensitiveList(@RequestBody SensitiveDto dto) {
        return adSensitiveService.sensitiveList(dto);
    }


    /**
     * 新增敏感词
     *
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/sensitive/save")
    public ResponseResult sensitiveSave(@RequestBody SensitiveDto dto) {
        return adSensitiveService.sensitiveSave(dto);
    }

    /**
     * 修改敏感词
     */
    @PutMapping("/api/v1/sensitive/update")
    public ResponseResult updateSensitive(@RequestBody SensitiveDto sensitiveDto) {
        adSensitiveService.updateSensitive(sensitiveDto);
        return ResponseResult.ok();
    }

    /**
     * 删除敏感词
     */
    @DeleteMapping("/api/v1/sensitive/del/{id}")
    public ResponseResult delSensitive(@PathVariable("id") Integer id) {
        adSensitiveService.delSensitive(id);
        return ResponseResult.ok();
    }



}
